package homework.api.day01;

import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        String str = "qwertyuiopasdfghjklzxcvbnm0123456789QWERTYUIOPASDFGHJKLZXCVBNM";
        Random rand = new Random();

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int index = rand.nextInt(str.length());
            builder.append(str.charAt(index));
        }

        System.out.println("验证码："+builder);
        while(true){
            System.out.println("请输入：");
            Scanner scan = new Scanner(System.in);
            String line = scan.nextLine();
            if(builder.toString().toLowerCase().equals(line.toLowerCase())){
                System.out.println("验证通过");
                break;
            }else{
                System.out.println("验证失败");
            }
        }
    }
}
